package com.zego.wawaji.ui.center.credit.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.zego.wawaji.base.data.BaseData;

import org.json.JSONObject;

/**
 * 积分信息
 * Created by Su on 2017/12/1.
 */
public class Credit extends BaseData implements Parcelable {
    private String createTime;   // 记录时间
    private String remark;        // 说明
    private int wwPoint;         // 积分
    private int wwTypeId;        // 娃娃种类id
    private int getType;         // 积分获取类型

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);

        this.setCreateTime(jsonObject.optString("CreateTime"));
        this.setRemark(jsonObject.optString("Remark"));
        this.setWwPoint(jsonObject.optInt("WwPoint"));
        this.setWwTypeId(jsonObject.optInt("WwTypeId"));
        this.setGetType(jsonObject.optInt("GetType"));
    }

    /**
     * 获取积分种类描述
     */
    public String getTypeStr() {
        String strType = "抓娃娃";
        switch (getGetType()) {
            case 2:
                strType = "兑换娃娃币";
                break;
        }
        return strType;
    }

    public int getGetType() {
        return getType;
    }

    public void setGetType(int getType) {
        this.getType = getType;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public int getWwPoint() {
        return wwPoint;
    }

    public void setWwPoint(int wwPoint) {
        this.wwPoint = wwPoint;
    }

    public int getWwTypeId() {
        return wwTypeId;
    }

    public void setWwTypeId(int wwTypeId) {
        this.wwTypeId = wwTypeId;
    }

    public Credit() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.createTime);
        dest.writeString(this.remark);
        dest.writeInt(this.wwPoint);
        dest.writeInt(this.wwTypeId);
        dest.writeInt(this.getType);
    }

    protected Credit(Parcel in) {
        this.createTime = in.readString();
        this.remark = in.readString();
        this.wwPoint = in.readInt();
        this.wwTypeId = in.readInt();
        this.getType = in.readInt();
    }

    public static final Creator<Credit> CREATOR = new Creator<Credit>() {
        @Override
        public Credit createFromParcel(Parcel source) {
            return new Credit(source);
        }

        @Override
        public Credit[] newArray(int size) {
            return new Credit[size];
        }
    };
}
